<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:template match="/offices">
    <xsl:apply-templates select="group" />
  </xsl:template>

  <xsl:template match="group">
    <div class="textContainer">
      <h3>
        <xsl:value-of select="@name" />
      </h3>
    </div>
    <div class="faqContainer">
      <ul>
        <li class="faqPanel">
          <ul class="faqItem">
            <xsl:apply-templates select="branch" />
          </ul>
        </li>
      </ul>
    </div>
    <br />
    <br />
  </xsl:template>

  <xsl:template match="branch">
    <li class="">
      <a class="faqHeader" href="#bishan">
        <xsl:attribute name="href">
          <xsl:value-of select="name"/>
        </xsl:attribute>
        <xsl:value-of select="name"></xsl:value-of>
        <xsl:if test="prevKnownAs != ''">
          (Previously known as <xsl:value-of select="prevKnownAs"/>)
        </xsl:if>
      </a>
      <a class="faqBody" style="display: none;">
        <xsl:attribute name="name">
          <xsl:value-of select="name"/>
        </xsl:attribute>
        <xsl:apply-templates select="address" />
        <xsl:apply-templates select="contact" />
		<xsl:apply-templates select="website" />
      </a>
    </li>
  </xsl:template>

  <xsl:template match="address">
    <xsl:for-each select="line">
      <xsl:value-of select="."/>
      <br/>
    </xsl:for-each>
  </xsl:template>

  <xsl:template match="contact">
    <xsl:if test="count(phone) != 0">
      Tel:
    </xsl:if>
    <xsl:apply-templates select="phone" />

    <xsl:if test="count(fax) != 0">
      Fax:
    </xsl:if>
    <xsl:apply-templates select="fax" />
    <br/>
  </xsl:template>

  <xsl:template match="phone">
    <xsl:value-of select="."/>
    <br/>
  </xsl:template>

  <xsl:template match="fax">
    <xsl:value-of select="."/>
    <br/>
  </xsl:template>
  
  <xsl:template match="website">
  	<xsl:if test="count(link) != 0">
		<a>
			<xsl:attribute name="href">link<xsl:value-of select="link"/>
		</a>
	</xsl:if>
	<xsl:apply-templates select="link" />
	<br/>
  </xsl:template>
  
  <xsl:template match="link">
    <xsl:value-of select="."/>
    <br/>
  </xsl:template>

</xsl:stylesheet>